package com.yiqi.liebang.feature.home.model;

import com.baiiu.filter.ClassifyBo;
import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.liebang.entity.bo.ExpertBo;
import com.yiqi.liebang.entity.bo.PeopleBo;
import com.yiqi.liebang.entity.bo.SearchFriendBo;
import com.yiqi.liebang.feature.home.contract.ClassifyContract;
import com.yiqi.liebang.feature.home.dependencies.classsify.DaggerClassifyModelComponent;
import com.yiqi.liebang.framework.api.ApiLib;
import com.yiqi.liebang.framework.api.HomeApi;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;

public class ClassifyModel implements ClassifyContract.Model {

    @Inject
    HomeApi api;


    @Inject
    public ClassifyModel() {

        DaggerClassifyModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }


    @Override
    public Observable<List<ClassifyBo>> getClassifyData() {
        return api.getAllClassify().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<List<SearchFriendBo.UserFriendBean>> getClassifyExpert(ClassifyBo classifyBo) {
        return api.getExpertListByType(classifyBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> getUserLabelByType(PeopleBo peopleBo) {
        return api.getLabelsByUser(peopleBo).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<List<ClassifyBo>> getQuestionClassify() {
        return api.getLabelsQuestion().compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}
